package Product;

import ConnnectData.DataConnect;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
import javax.swing.JOptionPane;

import java.util.Hashtable;
import validate.CheckForm;

/**
 *
 * @author langtustupid
 */
public class Add_Product_11 extends javax.swing.JFrame {

    Connection Con;
    Statement Sta;
    Statement Sta1;
    ResultSet Res;
    ResultSet Res1;
    Hashtable HTProductID = new Hashtable();
    Hashtable htSupplierName = new Hashtable();

    public Add_Product_11() {
        initComponents();

        try {
            Con = DataConnect.connectDB();
            Sta = Con.createStatement();
            Sta1 = Con.createStatement();

            String sql = "Select * from Product_Category";
            Res = Sta.executeQuery(sql);
            String sql1 = "Select * from Supplier";
            Res1 = Sta1.executeQuery(sql1);

        } catch (Exception e) {
            e.printStackTrace();
        }
        jComboBox_CategoryName.addItem("- Select -");
        try {
            while (Res.next()) {
                jComboBox_CategoryName.addItem(Res.getString("Category_Name"));
                HTProductID.put(Res.getString("Category_Name"), Res.getString("Category_Id"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        jComboBox_SupplierName.addItem("- Select -");
        try {
            while (Res1.next()) {
                jComboBox_SupplierName.addItem(Res1.getString("Supplier_Name"));
                htSupplierName.put(Res1.getString("Supplier_Name"), Res1.getString("Supplier_Id"));
            }
        } catch (Exception e) {
        }
        Reset();
    }

    public void AddProduct() {
        //
        if (jTextField_Productname.getText().equals("")) {
            jLabel_msProductname.setText("Name not null !");
            jTextField_Productname.requestFocus();
            return;
        }
        if (jTextField_Productname.getText().length() > 40) {
            jLabel_msProductname.setText("Name must be less than 40 characters !");
            jTextField_Productname.requestFocus();
            return;
        }
        //
        if (jTextField_ProductUnit.getText().equals("")) {
            jLabel_msProductunit.setText("Unit not null !");
            jTextField_ProductUnit.requestFocus();
            return;
        }
        if (jTextField_ProductUnit.getText().length() > 10) {
            jLabel_msProductunit.setText("Unit must be less than 10 characters !");
            jTextField_ProductUnit.requestFocus();
            return;
        }
        //
        if (jTextField_Productprice.getText().equals("")) {
            jLabel_msProductprice.setText("Price not null !");
            jTextField_Productprice.requestFocus();
            return;
        }
        if (CheckForm.isNumberic(jTextField_Productprice.getText()) == false) {
            jLabel_msProductprice.setText("Price not validate !");
            jTextField_Productprice.requestFocus();
            return;
        }
        //
        if (jTextField_Productquantity.getText().equals("")) {
            jLabel_msProductquantity.setText("Quantity not null !");
            jTextField_Productquantity.requestFocus();
            return;
        }
        if (CheckForm.isNumberic(jTextField_Productquantity.getText()) == false) {
            jLabel_msProductquantity.setText("Quantity not valide !");
            jTextField_Productquantity.requestFocus();
            return;
        }

        if (jComboBox_CategoryName.getSelectedIndex() == 0) {
            jLabel_msCategoryname.setText("You need choose Category");
            jComboBox_CategoryName.requestFocus();
            return;
        }
        if (jComboBox_SupplierName.getSelectedIndex() == 0) {
            jLabel_msSuppliername.setText("You need choose Supplier");
            jComboBox_SupplierName.requestFocus();
            return;
        }


        String catatemp = (String) HTProductID.get(jComboBox_CategoryName.getSelectedItem().toString().trim());
        String supTem = (String) htSupplierName.get(jComboBox_SupplierName.getSelectedItem().toString().trim());
        try {
            Sta.executeUpdate("Insert into Product(Product_Name,Product_Unit,Product_Price,Product_Quantity,Product_Description"
                    + ",Category_Id,Supplier_Id)  values(' " + jTextField_Productname.getText() + " ',' "
                    + jTextField_ProductUnit.getText() + " ',' " + jTextField_Productprice.getText() + " ',"
                    + jTextField_Productquantity.getText() + ",' " + jTextArea_ProductDescription.getText() + " ',"
                    + HTProductID.get(jComboBox_CategoryName.getSelectedItem().toString().trim()) + " , "
                    + htSupplierName.get(jComboBox_SupplierName.getSelectedItem().toString().trim()) + " )");
            this.dispose();
            JOptionPane.showMessageDialog(null, "Created successful new Product");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void Reset() {
        jTextField_Productname.setText("");
        jTextField_ProductUnit.setText("");
        jTextField_Productprice.setText("");
        jTextArea_ProductDescription.setText("");
        jTextField_Productquantity.setText("");
        jComboBox_CategoryName.setSelectedIndex(0);
        jComboBox_SupplierName.setSelectedIndex(0);
        jLabel_msProductname.setText("");
        jLabel_msProductunit.setText("");
        jLabel_msProductprice.setText("");
        jLabel_msProductquantity.setText("");
        jLabel_msCategoryname.setText("");
        jLabel_msSuppliername.setText("");

    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextField_Productname = new javax.swing.JTextField();
        jLabel_msProductname = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel_msProductunit = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel_msProductprice = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel_msProductquantity = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel_msCategoryname = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel_msSuppliername = new javax.swing.JLabel();
        jButton_Add = new javax.swing.JButton();
        jButton_Close = new javax.swing.JButton();
        jLabel21 = new javax.swing.JLabel();
        jTextField_Productprice = new javax.swing.JTextField();
        jTextField_Productquantity = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea_ProductDescription = new javax.swing.JTextArea();
        jLabel10 = new javax.swing.JLabel();
        jComboBox_CategoryName = new javax.swing.JComboBox();
        jComboBox_SupplierName = new javax.swing.JComboBox();
        jTextField_ProductUnit = new javax.swing.JTextField();
        jButton_Reset = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Add Product");
        setResizable(false);

        jPanel1.setBackground(new java.awt.Color(204, 255, 255));

        jLabel1.setFont(new java.awt.Font("Times New Roman", 0, 18));
        jLabel1.setText("Add Product");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(241, 241, 241)
                .addComponent(jLabel1)
                .addContainerGap(275, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel1)
                .addContainerGap(38, Short.MAX_VALUE))
        );

        jLabel2.setText("Product Name :");

        jTextField_Productname.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField_ProductnameFocusLost(evt);
            }
        });

        jLabel_msProductname.setForeground(new java.awt.Color(255, 0, 0));
        jLabel_msProductname.setText("Message");

        jLabel4.setText("Product Unit :");

        jLabel_msProductunit.setForeground(new java.awt.Color(255, 0, 0));
        jLabel_msProductunit.setText("Message");

        jLabel6.setText("Product Price :");

        jLabel_msProductprice.setForeground(new java.awt.Color(255, 0, 0));
        jLabel_msProductprice.setText("Message");

        jLabel8.setText("Product Quantity :");

        jLabel_msProductquantity.setForeground(new java.awt.Color(255, 0, 0));
        jLabel_msProductquantity.setText("Message");

        jLabel11.setText("Product Description :");

        jLabel12.setText("Catagory Name :");

        jLabel_msCategoryname.setForeground(new java.awt.Color(255, 0, 0));
        jLabel_msCategoryname.setText("Message");

        jLabel15.setText("Supplier Name :");

        jLabel_msSuppliername.setForeground(new java.awt.Color(255, 0, 0));
        jLabel_msSuppliername.setText("Message");

        jButton_Add.setText("Add Product");
        jButton_Add.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_AddActionPerformed(evt);
            }
        });

        jButton_Close.setText("Close");
        jButton_Close.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_CloseActionPerformed(evt);
            }
        });

        jLabel21.setForeground(new java.awt.Color(255, 0, 0));
        jLabel21.setText("Note: You need to enter complete information into the fields marked (*)");

        jTextField_Productprice.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField_ProductpriceFocusLost(evt);
            }
        });

        jTextField_Productquantity.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField_ProductquantityFocusLost(evt);
            }
        });

        jTextArea_ProductDescription.setColumns(20);
        jTextArea_ProductDescription.setRows(5);
        jScrollPane1.setViewportView(jTextArea_ProductDescription);

        jLabel10.setText(".000 VND");

        jComboBox_CategoryName.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jComboBox_CategoryNameFocusLost(evt);
            }
        });

        jComboBox_SupplierName.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jComboBox_SupplierNameFocusLost(evt);
            }
        });

        jTextField_ProductUnit.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField_ProductUnitFocusLost(evt);
            }
        });

        jButton_Reset.setText("Reset");
        jButton_Reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_ResetActionPerformed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel3.setForeground(new java.awt.Color(255, 0, 0));
        jLabel3.setText("*");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel5.setForeground(new java.awt.Color(255, 0, 0));
        jLabel5.setText("*");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel7.setForeground(new java.awt.Color(255, 0, 0));
        jLabel7.setText("*");

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel9.setForeground(new java.awt.Color(255, 0, 0));
        jLabel9.setText("*");

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel13.setForeground(new java.awt.Color(255, 0, 0));
        jLabel13.setText("*");

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel14.setForeground(new java.awt.Color(255, 0, 0));
        jLabel14.setText("*");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(118, 118, 118)
                .addComponent(jLabel21)
                .addContainerGap(147, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(88, 88, 88)
                .addComponent(jButton_Add)
                .addGap(31, 31, 31)
                .addComponent(jButton_Reset, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(36, 36, 36)
                .addComponent(jButton_Close, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(177, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(73, 73, 73)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(jLabel15)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4)
                    .addComponent(jLabel6)
                    .addComponent(jLabel8)
                    .addComponent(jLabel11))
                .addGap(48, 48, 48)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jTextField_Productquantity, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(1, 1, 1)
                                .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel_msProductquantity))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField_Productprice, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
                                    .addComponent(jTextField_ProductUnit, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel10))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel_msProductunit)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel_msProductprice))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jComboBox_SupplierName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jComboBox_CategoryName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(54, 54, 54)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel_msCategoryname)
                            .addComponent(jLabel_msSuppliername)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTextField_Productname, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(5, 5, 5)
                        .addComponent(jLabel_msProductname))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(148, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(33, 33, 33)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextField_Productname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel_msProductname))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextField_ProductUnit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel_msProductunit)
                    .addComponent(jLabel5))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextField_Productprice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jLabel13)
                    .addComponent(jLabel_msProductprice))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextField_Productquantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel_msProductquantity)
                    .addComponent(jLabel14))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jComboBox_CategoryName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel_msCategoryname))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(jComboBox_SupplierName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel_msSuppliername))
                .addGap(56, 56, 56)
                .addComponent(jLabel21)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_Add)
                    .addComponent(jButton_Reset)
                    .addComponent(jButton_Close))
                .addGap(30, 30, 30))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_ResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_ResetActionPerformed
        Reset();
    }//GEN-LAST:event_jButton_ResetActionPerformed

    private void jButton_AddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_AddActionPerformed
        AddProduct();
    }//GEN-LAST:event_jButton_AddActionPerformed

    private void jButton_CloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_CloseActionPerformed
        int Close = JOptionPane.showConfirmDialog(null, "Are you sure want close !");
        if (Close == 0) {
            this.dispose();
        }
    }//GEN-LAST:event_jButton_CloseActionPerformed

    private void jTextField_ProductnameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField_ProductnameFocusLost
        if (!jTextField_Productname.getText().equals("")) {
            jLabel_msProductname.setText("");
        }
    }//GEN-LAST:event_jTextField_ProductnameFocusLost

    private void jTextField_ProductUnitFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField_ProductUnitFocusLost
        if (!jTextField_ProductUnit.getText().equals("")) {
            jLabel_msProductunit.setText("");
        }

    }//GEN-LAST:event_jTextField_ProductUnitFocusLost

    private void jTextField_ProductpriceFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField_ProductpriceFocusLost
        if (!jTextField_Productprice.getText().equals("")) {
            jLabel_msProductprice.setText("");
        }

    }//GEN-LAST:event_jTextField_ProductpriceFocusLost

    private void jTextField_ProductquantityFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField_ProductquantityFocusLost
        if (!jTextField_Productquantity.getText().equals("")) {
            jLabel_msProductquantity.setText("");
        }

    }//GEN-LAST:event_jTextField_ProductquantityFocusLost

    private void jComboBox_CategoryNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBox_CategoryNameFocusLost
        if (jComboBox_CategoryName.getSelectedIndex() != 0) {
            jLabel_msCategoryname.setText("");
        }
    }//GEN-LAST:event_jComboBox_CategoryNameFocusLost

    private void jComboBox_SupplierNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBox_SupplierNameFocusLost
        if (jComboBox_SupplierName.getSelectedIndex() != 0) {
            jLabel_msSuppliername.setText("");
        }
    }//GEN-LAST:event_jComboBox_SupplierNameFocusLost

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Add_Product_11().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton_Add;
    private javax.swing.JButton jButton_Close;
    private javax.swing.JButton jButton_Reset;
    private javax.swing.JComboBox jComboBox_CategoryName;
    private javax.swing.JComboBox jComboBox_SupplierName;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabel_msCategoryname;
    private javax.swing.JLabel jLabel_msProductname;
    private javax.swing.JLabel jLabel_msProductprice;
    private javax.swing.JLabel jLabel_msProductquantity;
    private javax.swing.JLabel jLabel_msProductunit;
    private javax.swing.JLabel jLabel_msSuppliername;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea_ProductDescription;
    private javax.swing.JTextField jTextField_ProductUnit;
    private javax.swing.JTextField jTextField_Productname;
    private javax.swing.JTextField jTextField_Productprice;
    private javax.swing.JTextField jTextField_Productquantity;
    // End of variables declaration//GEN-END:variables
}
